ベクトルの正規化(Vector normalize)
ベクトル演算 — Godot Engine (stable)の日本語のドキュメント
正規化¶
Normalizing a vector means reducing its length to 1 while preserving its direction. This is done by dividing each of its components by its magnitude. Because this is such a common operation, Vector2 and Vector3 provide a method for normalizing:
大きさを持ったベクトルの長さを 1 にすること
GDScriptでは以下の関数が用意されている
a = a.normalized()
正規化はベクトルの長さで割り算するので、長さ 0 のベクトルは正規化できません。エラーになります。
注意
なぜ正規化するのか?
単位ベクトルにすると色々便利らしい
まだよく分かっていない